/*
 * @Author: sunzhijun 
 * @Date: 2019-07-30 14:55:34 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2020-03-20 14:37:58
 */
import React from 'react';
import './index.less';
import {createPage, high} from 'nc-lightapp-front';
import {render} from 'src/hrpub/common/frame';
import MainAction from '../actions/main';
import HeaderAction from '../actions/header';
import ButtonAction from '../actions/btn';
import TableAction from '../actions/table';
import CardAction from '../actions/card';
import TreeAction from '../actions/tree';
import UniquemodalAction from '../actions/uniquemodal';
import Layout from 'src/hrpub/common/components/Layout';
import HeaderMiddleContent from '../components/Header';
import LeftTree from '../components/LeftTree';
import TableList from '../components/TableList';
import CardForm from '../components/CardForm';
import Footer from '../components/Footer';
import UniqueModal from '../components/UniqueModal';
import TerminationModal from '../components/TerminationModal';
import DieModal from '../components/DieModal';
import BatchEditModal from '../../../public/components/BatchEdit';
import SortModal from '../../../public/components/SortModal';
import EmptyData from "src/hrpub/common/components/emptyImg";
import nodeRefs from './functions/nodeRefs';
import FileManager from '../components/fileManager';
import BatchAddSub from '../../../public/components/BatchAddSub';
import {getAppPageConfig} from 'src/hrpub/common/utils/utils';
import ViewCard from 'src/hrpub/common/components/card-view';
import WpsModal from 'src/hrpub/common/components/wpsPreModel';

const {Header, Left, Content} = Layout;
const appConfig = getAppPageConfig();
const HomePage = render({
    actions: {
        mainAct: MainAction,
        headerAct: HeaderAction,
        btnAct: ButtonAction,
        tableAct: TableAction,
        cardAct: CardAction,
        treeAct: TreeAction,
        uniquemodalAct: UniquemodalAction
    }
})(({props, action, state}) => {
    const {main, meta, button, editTable, form} = props;
    const {PrintOutput} = high;
    const {language} = main;
    return (
        <Layout className="main-page">
            <HeaderMiddleContent
                {...props}
                action={action}
            />
            <div className="container nc-bill-card">
                <If condition={!!main.pk_org}>
                    <div className="table-con tree-table" style={{height: main.conHeight}}>
                        <If condition={!main.isCardForm}>
                            <div className="left tree-area">
                                {/* 左树 */}
                                <LeftTree
                                    {...props}
                                    action={action}
                                >
                                </LeftTree>
                            </div>
                            <div className="con table-area">
                                {/* 右侧Table列表 */}
                                <TableList
                                    {...props}
                                    action={action}
                                ></TableList>
                            </div>
                        </If>
                        <If condition={main.isCardForm}>
                            {/* 卡片区域 */}
                            <CardForm
                                {...props}
                                action={action}
                            ></CardForm>
                        </If>
                    </div>
                    <If condition={main.isShowSub}>
                        {/* 底部子集 */}
                        <Footer
                            {...props}
                            action={action}
                        >
                        </Footer>
                    </If>
                    {/* 人员唯一性信息弹窗 */}
                    <UniqueModal
                        {...props}
                        action={action}
                    >
                    </UniqueModal>
                    {/* 批量修改 */}
                    <BatchEditModal
                        {...props}
                        batchEditModalVisible={main.batchEditModalVisible}
                        updateState={action.headerAct.updateState}
                        // ref={ref => this.batchEdit = ref}
                        ref={node => nodeRefs.refs = node}
                        humanResourceOrganizationValue={main.pk_org}
                        selectedRows={main.selectedRows}
                        func_type={5}
                    />
                    {/* 终止关系 */}
                    <TerminationModal
                        {...props}
                        action={action}
                    ></TerminationModal>
                    {/* 身故处理 */}
                    <DieModal
                        {...props}
                        action={action}
                    ></DieModal>
                    {/* 排序 */}
                    <SortModal
                        {...props}
                        visible={main.sortModalVisible}
                        onSure={action.tableAct.getMainTableData}
                        onClose={action.headerAct.sortModalVisible}
                        templateId="sort"
                        func_type={5}
                    />
                    {/* 附件管理 */}
                    <FileManager
                        {...props}
                        action={action}
                    />
                    {/* 批量添加子集 */}
                    <BatchAddSub
                        {...props}
                        meta={meta}
                        editTable={editTable}
                        form={form}
                        visible={main.batchAddSubVisible}
                        func_type={5}
                        param_str={main.pk_psnjobStr}
                        pk_org={main.pk_org}
                        onClose={action.headerAct.setHiddenBatchAddSub}
                    />
                    {/* 打印输出 */}
                    <PrintOutput
                        ref={
                            node => nodeRefs.printOutputRefs = node
                        }
                        url='/nccloud/hrhi/psndoc/PsndocTemplatePrintAction.do'
                        data={main.printData}
                    >
                    </PrintOutput>
                    <ViewCard
                        {...props}
                        onRef={
                            node => nodeRefs.showCardViewRefs = node
                        }
                    ></ViewCard>
                    <WpsModal
                        {...props}
                        onRef={node => nodeRefs.wpsview = node}
                        appcode={'60071026'}
                        pk_org={main.pk_org}

                    />
                </If>
                <If condition={!main.pk_org}>
                    <EmptyData text={language['hi6007-000191']}></EmptyData>
                </If>
            </div>
        </Layout>
    );
});

export default createPage([{
    billtype: 'form',
    pagecode: appConfig.appcode,
    headcode: 'bd_psndoc'
}, {
    billtype: 'form',
    pagecode: appConfig.appcode,
    headcode: 'hi_psnjob_h',
}, {
    billtype: 'form',
    pagecode: appConfig.appcode,
    headcode: 'hi_psnorg_h',
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psnorg',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psnjob',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_parttime',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_trial',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_psnchg',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_work',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_edu',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_family',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_ctrt',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_ass',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_capa',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_train',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_cert',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_linkman',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_title',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_nationduty',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_langability',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_enc',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_pun',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_partylog',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_abroad',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_retire',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_speitem',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_wainfo',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_bminfo',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_qulify',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}, {
    billtype: 'card',
    pagecode: appConfig.appcode,
    bodycode: 'hi_psndoc_keypsn',
    headcode: 'bd_psndoc',
    tabletype: 'cardTable'
}])(HomePage);